<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>


<script type="text/javascript" src="js/jquery.itextclear.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('input[type=text], input[type=password], input[type=url], input[type=email], input[type=number], textarea', '.form').iTextClear();
    });
</script>
<!-- jQplot CSS -->

<link rel="stylesheet" media="screen" href="${ctx}/css/Tree.css"/>
<!-- jQplot CSS END -->

<!-- DATATABLES CSS -->
<link rel="stylesheet" media="screen" href="lib/datatables/css/vpad.css"/>
<script type="text/javascript" src="lib/datatables/js/jquery.dataTables.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        /*$('#example').dataTable({
            "sPaginationType": "full_numbers"
        });*/
    });
</script>
<!-- DATATABLES CSS END -->

<script>
    $(document).ready(function() {
        $('#simple-button').popover('#simple-popover', {});
        $('#top-button').popover('#top-popover', {preventLeft: true, preventRight: true, preventBottom:true});
    });
</script>
<style>
    .project_option_div {background-color: #ccddff;margin-top: -10px;text-align: right;}
    .project_option_div p {background-color: #eeeeff;}
    .project_option_div span {cursor: pointer;color: #000000;margin: 4px;}
    .w600 {width: 600px;}
</style>

<h1 class="page-title">工作说明书-添加</h1>

<form method="post" name="post_form" id="post_form" onreset="resetForm()">
<div class="container_12 clearfix leading">
<section class="tabs grid_12 leading">
<ul class="clearfix">
    <li><a href="#" class="current">指责及时间安排</a></li>
    <%--<li><a href="#">考核项目</a></li>--%>
    <li><a href="#">需具备的条件</a></li>
    <li><a href="#">工作时间和环境</a></li>
    <li><a href="#">工作关系</a></li>
</ul>
<section>

<DIV class="portlet">
    <header>
        <h5_n>${duty.dutyName}</h5_n>
        <h2>${duty.organization.fullName}</h2>
    </header>
    <section class="clearfix">
        <%--<div class="grid_3">
            <dl>
                <dt>职等</dt>
                <dd><h6>经理等级</h6>
                </dd>
            </dl>
        </div>
        <div class="grid_3">
            <dl>
                <dt>职级</dt>
                <dd><h6>1级</h6></dd>
            </dl>
        </div>--%>
        <div class="grid_3" style="width: 350px;">
            <dl>
                <dt>业务负责对象(上)</dt>
                <dd>
                    <h6>
                        <select style="opacity: 0;" id="pre_duty" name="jobSpecification.preDuty.id">
                            <s:iterator value="#request.duties" var="d" status="sta">
                            <option value="${d.id}">${d.organization.path}/${d.dutyName}</option>
                            </s:iterator>
                        </select>
                    </h6>
                </dd>

            </dl>
        </div>
        <div class="grid_3 omega">
            <dl>
                <dt>业务负责对象(下)</dt>
                <dd>
                    <h6>
                        <select style="opacity: 0;" id="next_duty" name="jobSpecification.nextDuty.id">
                            <s:iterator value="#request.duties" var="d" status="sta">
                            <option value="${d.id}">${d.organization.path}/${d.dutyName}</option>
                            </s:iterator>
                        </select>
                    </h6>
                </dd>
            </dl>
        </div>
    </section>
</DIV>

<section class="clearfix" style="display: block;">
    <Div class="grid_12 leading">
        <dl>
            <dt>岗位职责</dt>
            <dd><textarea placeholder="请输入岗位职责" rows="5" required="required" id="d_content" name="jobSpecification.taskContent" style="width:100%">${jobSpecification.taskContent}</textarea></dd>
            <dt style="padding-top:10px">主要工作项目</dt>
        </dl>

        <!--
        <div class="message info">
            <h3>立足岗位，做好员工的思想指导工作。</h3>
            <p>每周 30 时</p>
            <div class="progress"><span style="width: 33%;"><b>33%</b></span></div>
            <p>非常负责</p>
        </div>
        -->

        <s:iterator value="#request.projects" var="project" status="sta">
        <div id="old_project_list">
        <div class="message info" id="old_project_${project.id}">
            <h3>${project.content}</h3>
            <p>${project.rate}</p>
            <div class="progress"><span style="width: ${project.percent}%;"><b>${project.percent}%</b></span></div>
            <p>${project.degree}</p>
        </div>
        <div class="project_option_div" id="old_project_opt_${project.id}">
            <p><span class="button popover_button" onclick="onEditProject('old_project', '${project.id}','${project.content}','${project.rateDay}','${project.rateWeek}','${project.rateMonth}','${project.rateSeason}','${project.percent}','${project.degree}')">编辑</span><span class="button" onclick="onDelete('old_project','${project.id}')">删除</span></p>
        </div>
        </div>
        </s:iterator>

        <div id="project_list_div"/>
        <div class="portlet">
            <header>

            </header>
            <section class="clearfix">
                <div class="grid_12">
                    <dl>
                        <dt>责任细则</dt>
                        <dd>
                            <textarea placeholder="请输入岗位职责" rows="5" required="required" id="p_content" class="full"></textarea></dd>
                        <dt>工作频度</dt>
                        <dd>
                            每日<input type="text" id="p_rateDay" style="width:20%">
                            每周<input type="text" id="p_rateWeek" style="width:20%">
                            每月<input type="text" id="p_rateMonth" style="width:20%">
                            每季<input type="text" id="p_rateSeason" style="width:20%">
                        </dd>
                        <dt>占全部工时%</dt>
                        <dd><input type="text" id="p_percent" class="full"></dd>
                        <dt>负责程度</dt>
                        <dd><input type="text" id="p_degree" class="full"></dd>
                    </dl>
                    <div class="form-action clearfix">
                        <p style="padding-top:10px">
                            <a class="button" href="javascript:void(0)" onclick="addProject()"><span style="background:url(${ctx}/images/img/add.png)" class="icon">&nbsp;</span>新增项目</a>
                        </p>
                    </div>
                </div>
            </section>
        </div>
    </Div>
</section>

<%--
<section class="clearfix" style="display: none;">
    <header class="grid_12 alpha omega">

    </header>
    <Div class="grid_12 leading">
        <div class="grid_3">
            <dl>
                <dt>行政考核</dt>
                <dd><input type="text" id="d_xzExamine" name="jobSpecification.xzExamine" class="full"></dd>
                <dt>下属考核</dt>
                <dd><input type="text" id="d_xsExamine" name="jobSpecification.xsExamine" class="full"></dd>
            </dl>
        </div>
        <div class="grid_3">
            <dl>
                <dt>人事考核</dt>
                <dd><input type="text" id="d_rsExamine" name="jobSpecification.rsExamine" class="full"></dd>
                <dt>财务考核</dt>
                <dd><input type="text" id="d_cwExamine" name="jobSpecification.cwExamine" class="full"></dd>
            </dl>
        </div>
        <div class="grid_3">
            <dl>
                <dt>主管考核</dt>
                <dd><input type="text" id="d_zgExamine" name="jobSpecification.zgExamine" class="full"></dd>
                <dt>关键绩效指标考核</dt>
                <dd><input type="text" id="d_jxExamine" name="jobSpecification.jxExamine" class="full"></dd>
            </dl>
        </div>
        <div class="grid_3">
            <dl>
                <dt>同事考核</dt>
                <dd><input type="text" id="d_tsExamine" name="jobSpecification.tsExamine" class="full">
                </dd>
            </dl>
        </div>
    </Div>
</section>
--%>

<section class="clearfix" style="display: none;">
    <Div class="grid_12 leading">
        <div class="grid_3">
            <dl>
                <dt>性别</dt>
                <dd><input type="radio" value="male" id="form_male" name="jobSpecification.sex" style="opacity: 0;"> 先生
                    <input type="radio" value="female" id="form_female" name="jobSpecification.sex" style="opacity: 0;"> 女士
                    <input type="radio" value="none" id="form_none" name="jobSpecification.sex" style="opacity: 0;" checked="checked"> 不限
                </dd>
                <dt>英文程度</dt>
                <%--<dd><input type="text" id="d_english" name="jobSpecification.english" class="full"></dd>--%>
                <dd>
                    <select style="opacity: 0;" id="d_english" name="jobSpecification.english">
                        <option value="level_normal">一般</option>
                        <option value="level_ripe">熟练</option>
                        <option value="level_good">精通</option>
                    </select>
                </dd>
            </dl>
        </div>
        <div class="grid_3">
            <dl>
                <dt>学历</dt>
                <%--<dd><input type="text" id="d_education" name="jobSpecification.education" class="full"></dd>--%>
                <dd>
                    <select style="opacity: 0;" id="d_education" name="jobSpecification.education">
                        <option value="primary_school">小学</option>
                        <option value="junior_high_school">初中</option>
                        <option value="senior_high_school">高中</option>
                        <option value="junior_college">大专</option>
                        <option value="undergraduate_course">本科</option>
                        <option value="master">硕士</option>
                        <option value="doctor">博士</option>
                        <option value="postdoctor">博士后</option>
                    </select>
                </dd>
            </dl>
        </div>
        <div class="grid_3">
            <dl>
                <dt>培训</dt>
                <dd><input type="text" id="d_training" name="jobSpecification.training" class="full" value="${jobSpecification.training}"></dd>
            </dl>
        </div>
        <div class="grid_3">
            <dl>
                <dt>证书</dt>
                <dd><input type="text" id="d_certificate" name="jobSpecification.certificate" class="full" value="${jobSpecification.certificate}">
                </dd>
            </dl>
        </div>
    </Div>

    <Div class="grid_12 leading">
        <div class="grid_12">
            <dl>
                <dt>工作经验能力</dt>
                <dd><textarea style="width:100%" id="d_experience" name="jobSpecification.experience" required="required" rows="5" placeholder="请输入工作经验能力">${jobSpecification.experience}</textarea></dd>
            </dl>
        </div>
    </Div>

</section>
<section class="clearfix" style="display: none;">
    <Div class="grid_12 leading">
        <div class="grid_3">
            <dl>
                <dt>工作时间</dt>
                <dd><input type="text" id="d_jobTime" name="jobSpecification.jobTime" class="full" value="${jobSpecification.jobTime}"></dd>
            </dl>
        </div>
        <div class="grid_3">
            <dl>
                <dt>工作环境</dt>
                <dd><input type="text" id="d_jobEnvironment" name="jobSpecification.jobEnvironment" class="full" value="${jobSpecification.jobEnvironment}"></dd>
            </dl>
        </div>
    </Div>
</section>
<section class="clearfix" style="display: none;">
    <Div class="grid_12 leading">
        <div class="grid_3">
            <dl>
                <dt>可晋升职位</dt>
                <%--<dd><input type="text" id="d_jsJob" name="jobSpecification.jsJob" class="full"></dd>--%>
                <dd>
                    <select style="opacity: 0;" id="d_jsJob" name="jobSpecification.jsJob.id">
                        <s:iterator value="#request.duties" var="d" status="sta">
                        <option value="${d.id}">${d.dutyName}</option>
                        </s:iterator>
                    </select>
                </dd>
            </dl>
        </div>
        <div class="grid_3">
            <dl>
                <dt>可轮换职位</dt>
                <%--<dd><input type="text" id="d_lhJob" name="jobSpecification.lhJob" class="full"></dd>--%>
                <dd>
                    <select style="opacity: 0;" id="d_lhJob" name="jobSpecification.lhJob.id">
                        <s:iterator value="#request.duties" var="d" status="sta">
                        <option value="${d.id}">${d.dutyName}</option>
                        </s:iterator>
                    </select>
                </dd>
            </dl>
        </div>
        <div class="grid_3">
            <dl>
                <dt>可代理职位</dt>
                <%--<dd><input type="text" id="d_dlJob" name="jobSpecification.dlJob" class="full"></dd>--%>
                <dd>
                    <select style="opacity: 0;" id="d_dlJob" name="jobSpecification.dlJob.id">
                        <s:iterator value="#request.duties" var="d" status="sta">
                        <option value="${d.id}">${d.dutyName}</option>
                        </s:iterator>
                    </select>
                </dd>
            </dl>
        </div>
        <div class="grid_3">
            <dl>
                <dt>可晋升至此的职位</dt>
                <%--<dd><input type="text" id="d_jszcJob" name="jobSpecification.jszcJob" class="full"></dd>--%>
                <dd>
                    <select style="opacity: 0;" id="d_jszcJob" name="jobSpecification.jszcJob.id">
                        <s:iterator value="#request.duties" var="d" status="sta">
                        <option value="${d.id}">${d.dutyName}</option>
                        </s:iterator>
                    </select>
                </dd>
            </dl>
        </div>
    </Div>

</section>
</section>
</section>


<div class="tabs side grid_12 leading">
    <div class="clear"></div>
    <div class="grid_12">
        <div class="form-action clearfix">
            <p>
                <button type="button" class="button" onclick="checkForm()">${jobSpecification == null ? "添加" : "修改"}</button>
                <button type="reset" class="button">重置</button>
                <a href="#rank/job_specification.xhtml?operation=${operation}" class="button">
                    <span class="icon" style="background:url(${ctx}/images/img/arrow_undo.png)">&nbsp;</span>返回
                </a>
            </p>
        </div>
    </div>


</div>
</div>

<div class="clear"></div>
<input type="hidden" name="jobSpecification.duty.id" value="${duty.id}"/>
<input type="hidden" name="jobSpecification.id" value="${jobSpecification.id}"/>
<div id="hidden_div"></div>
</form>


<div id="simple-popover" class="popover w600">
    <header> 编辑工作项目</header>
    <section class="clearfix">
        <div class="grid_12 content" style="padding: 10px;">
            <dl>
                <dt>责任细则</dt>
                <dd>
                    <textarea placeholder="请输入岗位职责" rows="5" required="required" id="e_p_content" class="full"></textarea></dd>
                <dt>工作频度</dt>
                <dd>
                    每日<input type="text" id="e_p_rateDay" style="width:20%">
                    每周<input type="text" id="e_p_rateWeek" style="width:20%">
                    每月<input type="text" id="e_p_rateMonth" style="width:20%">
                    每季<input type="text" id="e_p_rateSeason" style="width:20%">
                </dd>
                <dt>占全部工时%</dt>
                <dd><input type="text" id="e_p_percent" class="full"></dd>
                <dt>负责程度</dt>
                <dd><input type="text" id="e_p_degree" class="full"></dd>
            </dl>
            <div class="form-action clearfix">
                <p style="padding-top:10px">
                    <input type="hidden" id="e_p_id" />
                    <input type="hidden" id="e_p_type" />
                    <a class="button" href="javascript:void(0)" onclick="editProject()"><span style="background:url(${ctx}/images/img/page_edit.png)" class="icon">&nbsp;</span>编辑</a>
                    <%--<a class="button" href="javascript:void(0)" onclick="hidePopup()"><span style="background:url(${ctx}/images/img/arrow_undo.png)" class="icon">&nbsp;</span>取消</a>--%>
                </p>
            </div>
        </div>
    </section>
</div>

<script type="text/javascript" src="${ctx}/js/Tree.js"></script>
<script type="text/javascript" src="${ctx}/js/global_util.js"></script>
<script type="text/javascript">
    $(function(){
        initForm();

        bindPopover();
    });

    function bindPopover(){
        //设置弹出框(jquery.popover)
        $("span.popover_button").each(function(){
            $(this).popover('#simple-popover', {});
        });
    }

    function initForm(){
        var jid = "${jobSpecification.id}";
        if(jid != null && jid != undefined && jid > 0){
            $("#pre_duty").val("${jobSpecification.preDuty.id}");
            $("#next_duty").val("${jobSpecification.nextDuty.id}");
            $("#d_english").val("${jobSpecification.english}");
            $("#d_education").val("${jobSpecification.education}");
            $("#d_jsJob").val("${jobSpecification.jsJob.id}");
            $("#d_lhJob").val("${jobSpecification.lhJob.id}");
            $("#d_dlJob").val("${jobSpecification.dlJob.id}");
            $("#d_jszcJob").val("${jobSpecification.jszcJob.id}");
            $("#form_${jobSpecification.sex}").attr("checked", true);
        }
    }

    function onDelete(type, id){
        if(!confirm("确定要删除工作项目吗？")){
            return;
        }

        //等待提交的
        if(type == "new_project"){
            $("#new_project_hidden_"+e_p_id).remove();
            $("#new_project_div_"+id).remove();
            $("#new_project_opt_"+id).remove();
            return;
        }

        var url = "${ctx}/ajax/project_remove.xhtml?project.id="+id;
        $.ajax(url, {
            type: "POST",
            data: null,
            dataType:"html",
            cache:false,
            success:function(a) {
                $("#old_project_"+id).remove();
                $("#old_project_opt_"+id).remove();
            },
            complete:function() {}
        });
    }

    //显示编辑弹出框
    function onEditProject(type, id, content, rateDay, rateWeek, rateMonth, rateSeason, percent, degree){
        //alert("id="+id+":\ncontent="+content+":\nrateDay="+rateDay+":\nrateWeek="+rateWeek+":\nrateMonth="+rateMonth+":\nrateSeason="+rateSeason+":\npercent="+percent+":\ndegree="+degree)
        $("#e_p_id").val(id);
        $("#e_p_type").val(type); //new_project, old_project
        $("#e_p_content").val(content);
        $("#e_p_rateDay").val(rateDay);
        $("#e_p_rateWeek").val(rateWeek);
        $("#e_p_rateMonth").val(rateMonth);
        $("#e_p_rateSeason").val(rateSeason);
        $("#e_p_percent").val(percent);
        $("#e_p_degree").val(degree);

    }
    //编辑
    function editProject(){
        //alert($("#simple-popover").serialize())
        var e_p_id = $("#e_p_id").val();
        var e_p_content = $("#e_p_content").val();
        var e_p_rateDay = $("#e_p_rateDay").val();
        var e_p_rateWeek = $("#e_p_rateWeek").val();
        var e_p_rateMonth = $("#e_p_rateMonth").val();
        var e_p_rateSeason = $("#e_p_rateSeason").val();
        var e_p_percent = $("#e_p_percent").val();
        var e_p_degree = $("#e_p_degree").val();

        if(e_p_id == null || e_p_id <= 0){
            hidePopup();
        }
        if(checkNull(e_p_content)){
            alert("请填写责任细则");
            return;
        }
        if(checkNull(e_p_rateDay) && checkNull(e_p_rateWeek) && checkNull(e_p_rateMonth) && checkNull(e_p_rateSeason)){
            alert("请填写工作频度");
            return;
        }
        if(checkNull(e_p_percent) || isNaN(e_p_percent) || parseFloat(e_p_percent) > 100 || parseFloat(e_p_percent) < 0){
            alert("请正确填写占全部工时百分比");
            return;
        }
        if(checkNull(e_p_degree)){
            alert("请填写负责程度");
            return;
        }

        //未保存到数据库的工作项目
        if($("#e_p_type").val() == "new_project"){
            var pObj = $("#new_project_hidden_"+e_p_id).children("input");
            $(pObj[0]).val(e_p_content)
            $(pObj[1]).val(e_p_rateDay)
            $(pObj[2]).val(e_p_rateWeek)
            $(pObj[3]).val(e_p_rateMonth)
            $(pObj[4]).val(e_p_rateSeason)
            $(pObj[5]).val(e_p_percent)
            $(pObj[6]).val(e_p_degree)
            var temp = createProjectHtml("new_project",e_p_id,e_p_content,e_p_rateDay,e_p_rateWeek,e_p_rateMonth,e_p_rateSeason,e_p_percent,e_p_degree);
            $("#new_project_div_"+e_p_id).html(temp);
            temp = createProjectOptHtml("new_project",e_p_id,e_p_content,e_p_rateDay,e_p_rateWeek,e_p_rateMonth,e_p_rateSeason,e_p_percent,e_p_degree);
            $("#new_project_opt_"+e_p_id).html(temp);
            hidePopup();
            return;
        }

        var project =
        {"project.id":e_p_id, "project.content":e_p_content, "project.rateDay":e_p_rateDay,
         "project.rateWeek":e_p_rateWeek, "project.rateMonth":e_p_rateMonth, "project.rateSeason":e_p_rateSeason,
         "project.percent":e_p_percent, "project.degree":e_p_degree
        };
        var url = "${ctx}/ajax/project_edit.xhtml";
        $.ajax(url, {
            type: "POST",
            data: project,
            dataType:"html",
            cache:false,
            success:function(a) {
                var temp = createProjectHtml("old_project",e_p_id,e_p_content,e_p_rateDay,e_p_rateWeek,e_p_rateMonth,e_p_rateSeason,e_p_percent,e_p_degree);
                $("#old_project_"+e_p_id).html(temp);
                temp = createProjectOptHtml("old_project",e_p_id,e_p_content,e_p_rateDay,e_p_rateWeek,e_p_rateMonth,e_p_rateSeason,e_p_percent,e_p_degree);
                $("#old_project_opt_"+e_p_id).html(temp);

                hidePopup();
            },
            complete:function() {}
        });
    }
    function hidePopup(){
        $("#simple-popover").hide();
        bindPopover();
    }

    //添加工作项目(未提交)
    function addProject(){
        var id = new Date().getTime();
        var p_content = $("#p_content").val();
        var p_rateDay = $("#p_rateDay").val();
        var p_rateWeek = $("#p_rateWeek").val();
        var p_rateMonth = $("#p_rateMonth").val();
        var p_rateSeason = $("#p_rateSeason").val();
        var p_percent = $("#p_percent").val();
        var p_degree = $("#p_degree").val();
        if(checkNull(p_content)){
            alert("请填写责任细则");
            return;
        }
        if(checkNull(p_rateDay) && checkNull(p_rateWeek) && checkNull(p_rateMonth) && checkNull(p_rateSeason)){
            alert("请填写工作频度");
            return;
        }
        if(checkNull(p_percent) || isNaN(p_percent) || parseFloat(p_percent) > 100 || parseFloat(p_percent) < 0){
            alert("请正确填写占全部工时百分比");
            return;
        }
        if(checkNull(p_degree)){
            alert("请填写负责程度");
            return;
        }

        var temp = "<div id='new_project_hidden_"+id+"'>"+
                        "<input type='hidden' name='p_content' value='"+p_content+"'>"+
                        "<input type='hidden' name='p_rateDay' value='"+p_rateDay+"'>"+
                        "<input type='hidden' name='p_rateWeek' value='"+p_rateWeek+"'>"+
                        "<input type='hidden' name='p_rateMonth' value='"+p_rateMonth+"'>"+
                        "<input type='hidden' name='p_rateSeason' value='"+p_rateSeason+"'>"+
                        "<input type='hidden' name='p_percent' value='"+p_percent+"'>"+
                        "<input type='hidden' name='p_degree' value='"+p_degree+"'>"+
                    "</div>"
        $("#hidden_div").append(temp);

        //new_project仅作待提交的project标识
        var temp = createProjectHtml("new_project",id,p_content,p_rateDay,p_rateWeek,p_rateMonth,p_rateSeason,p_percent,p_degree);
        $("#project_list_div").append(temp);
        temp = createProjectOptHtml("new_project",id,p_content,p_rateDay,p_rateWeek,p_rateMonth,p_rateSeason,p_percent,p_degree);
        $("#project_list_div").append(temp);
        bindPopover();

        $("#p_content").val("");
        $("#p_rateDay").val("");
        $("#p_rateWeek").val("");
        $("#p_rateMonth").val("");
        $("#p_rateSeason").val("");
        $("#p_percent").val("");
        $("#p_degree").val("");
    }

    function checkForm(){
        if(checkNull($("#d_content").val())){
            alert("请输入岗位职责");
            return;
        }
        /*
        if(checkNull($("#d_xzExamine").val())){
            alert("请输入行政考核");
            return;
        }
        if(checkNull($("#d_rsExamine").val())){
            alert("请输入人事考核");
            return;
        }
        if(checkNull($("#d_zgExamine").val())){
            alert("请输入主管考核");
            return;
        }
        if(checkNull($("#d_tsExamine").val())){
            alert("请输入同事考核");
            return;
        }
        if(checkNull($("#d_xsExamine").val())){
            alert("请输入下属考核");
            return;
        }
        if(checkNull($("#d_cwExamine").val())){
            alert("请输入财务考核");
            return;
        }
        if(checkNull($("#d_jxExamine").val())){
            alert("请输入关键绩效指标考核");
            return;
        }
        */

        //var sex = $('input[@type=radio][@name="jobSpecification.sex"][@checked]').val();
        var sex;
        $("input[type='radio'][name='jobSpecification.sex']").each(function(){
            if($(this).parent(".checked").length == 1){
                sex = $(this).val();
                return false; //退出each(相当于break, return true相当于continue)
            }
        });

        if(checkNull($("#d_education").val())){
            alert("请输入学历");
            return;
        }
        if(checkNull($("#d_training").val())){
            alert("请输入培训");
            return;
        }
        if(checkNull($("#d_certificate").val())){
            alert("请输入证书");
            return;
        }
        if(checkNull($("#d_english").val())){
            alert("请输入英文程度");
            return;
        }
        if(checkNull($("#d_experience").val())){
            alert("请输入工作经验能力");
            return;
        }

        if(checkNull($("#d_jobTime").val())){
            alert("请输入工作时间");
            return;
        }
        if(checkNull($("#d_jobEnvironment").val())){
            alert("请输入工作环境");
            return;
        }

        if (checkNull($("#d_jsJob").val())) {
            alert("请输入可晋升职位");
            return;
        }
        if (checkNull($("#d_lhJob").val())) {
            alert("请输入可轮换职位");
            return;
        }
        if (checkNull($("#d_dlJob").val())) {
            alert("请输入可代理职位");
            return;
        }
        if (checkNull($("#d_jszcJob").val())) {
            alert("请输入可晋升至此的职位");
            return;
        }

        var url = "${ctx}/rank/job_specification_create.xhtml";
        $.ajax(url, {
            type: "POST",
            data: $("#post_form").serialize(),
            dataType:"html",
            cache:false,
            success:function(a) {
                return pageDownloaded(a, url);
            },
            complete:function() {}
        });
    }

    function resetForm(){
        $("div.new_project").remove(); //删除class为new_project的div
        $("#hidden_div").empty(); //清除hidden_div
    }

    //type:new_project or old_project
    function createProjectHtml(type, p_id,p_content,p_rateDay,p_rateWeek,p_rateMonth,p_rateSeason,p_percent,p_degree){
        var rate = "";
        if(!checkNull(p_rateDay)){ rate += '每天 '+ p_rateDay + ' 时 '; }
        if(!checkNull(p_rateWeek)){ rate += '每周 '+ p_rateWeek + ' 时 '; }
        if(!checkNull(p_rateMonth)){ rate += '每月 '+ p_rateMonth + ' 时 '; }
        if(!checkNull(p_rateSeason)){ rate += '每季 '+ p_rateSeason + ' 时 '; }
        var temp =
            '<div class="message info '+type+'" id="'+type+'_div_'+p_id+'">'+
                '<h3>'+p_content+'</h3>'+
                '<p>'+rate+'</p>'+
                '<div class="progress"><span style="width: '+p_percent+'%;"><b>'+p_percent+'%</b></span></div>'+
                '<p>'+p_degree+'</p>'+
            '</div>';

        return temp;
    }
    function createProjectOptHtml(type, p_id,p_content,p_rateDay,p_rateWeek,p_rateMonth,p_rateSeason,p_percent,p_degree){
        var temp =
            '<div class="project_option_div" id="'+type+'_opt_'+p_id+'">'+
                '<p>'+
                '<span class="button popover_button" onclick="onEditProject(\''+type+'\',\''+p_id+'\',\''+p_content+'\',\''+p_rateDay+'\',\''+p_rateWeek+'\',\''+p_rateMonth+'\',\''+p_rateSeason+'\',\''+p_percent+'\',\''+p_degree+'\')">编辑</span>'+
                '<span class="button" onclick="onDelete(\''+type+'\', \''+p_id+'\')">删除</span>'+
                '</p>'+
            '</div>'

        return temp;
    }
</script>

    